package cn.tedu.mall.seckill.exception;

import cn.tedu.mall.common.exception.CoolSharkServiceException;
import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.common.restful.ResponseCode;
import cn.tedu.mall.pojo.seckill.dto.SeckillOrderAddDTO;
import com.alibaba.csp.sentinel.slots.block.BlockException;

public class SeckillBlockHandler {
    //自定义限流方法
    /*
      1.访问修饰符是public
      2.修饰符需要添加static
      3.返回值类型需要和被限流的方法一致
      4.方法参数需要和被限流的方法参数一致，除此之外还需要添加BlockException异常类
     */
    public static JsonResult blockHandler(
            String randCode, SeckillOrderAddDTO seckillOrderAddDTO,
            BlockException blockException
            ){
        return JsonResult.failed(new CoolSharkServiceException(ResponseCode.BAD_REQUEST,"服务器繁忙，请稍后重试~"));
    }
}
